﻿new Module('CobraCms.Js', function () {
    var Class = Phosphor.Utilities.Class;

    var ContentTreeUtilities = new Class({
        BuildJsTreeNode: function (contentTreeNode) {
            var jsTreeNode = {};
            jsTreeNode.title = contentTreeNode.Name;
            jsTreeNode.contentNode = contentTreeNode;
            jsTreeNode.children = [];
            jsTreeNode.isFolder = true;
            jsTreeNode.isLazy = true;
            jsTreeNode.key = contentTreeNode.NodeId;
            for (var i = 0; i < contentTreeNode.PreExpandedChildren.length; i++) {
                var childContentNode = contentTreeNode.PreExpandedChildren[i];
                var childTreeNode = CobraCms.Js.ContentTreeUtilities.BuildJsTreeNode(childContentNode);
                jsTreeNode.children.push(childTreeNode);
            }
            return jsTreeNode;
        }
    });

    this.ContentTreeUtilities = new ContentTreeUtilities();
});